package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.HealthTestDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;

import com.itheima.pojo.HealthTest;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

@Service
public class HealthTestServiceImpl implements HealthTestService {
    @Autowired
    private HealthTestDao healthTestDao;
    @Override
    public PageResult find(QueryPageBean queryPageBean) {
        Integer currentPage = queryPageBean.getCurrentPage();
        Integer pageSize = queryPageBean.getPageSize();
        PageHelper.startPage(currentPage,pageSize);//分页插件，会在执行sql之前将分页关键字追加到SQL后面
        Page<HealthTest> page = healthTestDao.find();
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void delete(Integer id) {
        healthTestDao.deleteHealthSetmmeal(id);
        healthTestDao.deleteHealthCheckitem(id);
    }

    @Override
    public void importHealthTest(Map<String, Object> map) {
        healthTestDao.importHealthTest(map);
    }

    @Override
    public void add(Map<String, Object> map) {
        healthTestDao.add(map);
    }

    @Override
    public Integer findById(Map<String, Object> setmeal) {


        return healthTestDao.findById(setmeal);
    }
}
